<!DOCTYPE html>
<html>
<head>
	<meta charset="UTF-8">
	<title>练习</title>
</head>
<body>
	<script type="text/javascript">
		
		// 1.获取min到max之间的整数 (1~100)
		function random(max,min){
			return Math.floor(Math.random() * (max-min) + min);
		}

		// 2.获取随机颜色  rgb(0~255,0~255,0~255);
		function randomColor(){

			// var result
			var r = random(0,256),g = random(0,256),b = random(0,256);
			// 模板字符串 ``
			var result = `rgb(${r},${g},${b})`;
			return result;
		}
		var rc = randomColor();
		console.log(rc);
		document.body.style.backgroundColor = rc;


		// 3.随机验证码   四位  数字+ 字母 (大写) 65Yz
		function creatCode(){
			// 设置默认的空的字符串  
			var  code = '';
			// 设置长度 
			var codeLength = 4;
			var randomCode = [0,1,2,3,4,5,6,7,8,9,'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R', 'S','T','U','V','W','X','Y','Z'];
			for(var i  = 0; i < codeLength; i++){
				// 设置随机范围 0~36
				var index = random(0,36);
				code +=  randomCode[index];
			}
			return code;
		}
		var rndcode = creatCode();
		console.log(rndcode);
		document.write(`<h1>${rndcode}</h1`)

	</script>
	
</body>
</html>